#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
	if(a % b == 0)return b;
	else return gcd(b, a % b);
}

void solve(){
	int n;
	cin >> n;
	set<ll> a;
	for(int i = 0; i < n; i++){
		ll num;
		cin >> num;
		a.insert(num);
	}

	ll res = 1e18;
	for(ll x : a){
		ll t = 2;
		while(gcd(x, t) != 1){
			t++;
		}
		res = min(res, t);
	}

	cout << res << '\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}